/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Frontera;

import Entidad.Cliente;
import control.ControlCliente;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author Juan
 */
public class FRegistroClientes extends javax.swing.JFrame {

    /**
     * Creates new form FRegistroClientes
     */
    
    public FRegistroClientes() {
        initComponents();       
        this.setLocationRelativeTo(null);
    }
    
    public void setPadre(JFrame padre) {
        this.padre = padre;
    }
    
    public void cerrar(){ //SIEMPRE llamar este método para cerrar la ventana.
        padre.setEnabled(true);
        if (padre instanceof FRegistroSolicitud) {
            FRegistroSolicitud frs = (FRegistroSolicitud) padre;
            frs.cargarClientes();
        }
        padre.toFront();
        dispose();
    }
    
    private void desactivarTF(JTextField textField, String mensaje) {
        textField.setEditable(false);
        textField.setText(mensaje);
    }
    
    public void inicializarParaConsulta(Cliente cliente) {
        BAceptar.setVisible(false);
        BCancelar.setText("Regresar");
        desactivarTF(TFNombreCliente, cliente.getNombre());
        desactivarTF(TFIdentificacion, cliente.getIdentificacion());
        RBCC.setEnabled(false);
        RBNIT.setEnabled(false);
        RBOtro.setEnabled(false);
        String identificacion = cliente.getTipoIdentificacion();
        switch (identificacion) {
            case "Cedula":
                RBCC.setEnabled(true);
                break;
            case "NIT":
                RBNIT.setSelected(true);
                break;
            default:
                RBOtro.setSelected(true);
                TFOtro.setEditable(false);
                TFOtro.setText(identificacion);
                break;
        }
        desactivarTF(TFTelefonos, cliente.getTelefonos());
        desactivarTF(TFTelefonosRetenciones, cliente.getTelefonosCertificados());
        desactivarTF(TFFax, cliente.getFax());
        desactivarTF(TFDireccion, cliente.getDireccion());
        CBCorrespondencia.setSelected(cliente.getCorrespondencia());
        CBCorrespondencia.setEnabled(false);
        CBDevolucionMuestras.setSelected(cliente.getDevolucionMuestras());
        CBDevolucionMuestras.setEnabled(false);
        CBEnvioResultados.setSelected(cliente.getEnvioResultados());
        CBEnvioResultados.setEnabled(false);
        CBFacturacion.setSelected(cliente.getFacturacion());
        CBFacturacion.setEnabled(false);
        desactivarTF(TFCiudad, cliente.getCiudad());
        String condicionesFacturacion = cliente.getCondicionesFacturacion();
        TFCondicionesFacturacion.setEnabled(true);
        if (condicionesFacturacion.equals("Al recibir la Muestra")) {
            CBCondicionesFacturacion.setSelectedIndex(0);
            TFCondicionesFacturacion.setEditable(false);
        } else if (condicionesFacturacion.startsWith("Fe")) {
            CBCondicionesFacturacion.setSelectedIndex(1);
            desactivarTF(TFCondicionesFacturacion, condicionesFacturacion.substring(29));
        } else if (condicionesFacturacion.startsWith("Lu")) {
            CBCondicionesFacturacion.setSelectedIndex(2);
            desactivarTF(TFCondicionesFacturacion, condicionesFacturacion.substring(19));
        } else if (condicionesFacturacion.startsWith("Fo")) {
            CBCondicionesFacturacion.setSelectedIndex(3);
            desactivarTF(TFCondicionesFacturacion, condicionesFacturacion.substring(14));
        }
        CBCondicionesFacturacion.setEnabled(false);
        desactivarTF(TFPersonaContacto, cliente.getPersonaContacto());
        desactivarTF(TFEmailsResultados, cliente.getEmailsResultados());
        desactivarTF(TFEmailsOtros, cliente.getEmailsComunicacion());
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BGIdentificacion = new javax.swing.ButtonGroup();
        PRegistroCliente = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        TFNombreCliente = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        CBCorrespondencia = new javax.swing.JCheckBox();
        CBDevolucionMuestras = new javax.swing.JCheckBox();
        CBEnvioResultados = new javax.swing.JCheckBox();
        CBFacturacion = new javax.swing.JCheckBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        TFIdentificacion = new javax.swing.JTextField();
        RBCC = new javax.swing.JRadioButton();
        RBNIT = new javax.swing.JRadioButton();
        RBOtro = new javax.swing.JRadioButton();
        TFOtro = new javax.swing.JTextField();
        TFTelefonos = new javax.swing.JTextField();
        TFTelefonosRetenciones = new javax.swing.JTextField();
        TFFax = new javax.swing.JTextField();
        TFDireccion = new javax.swing.JTextField();
        TFCiudad = new javax.swing.JTextField();
        CBCondicionesFacturacion = new javax.swing.JComboBox();
        TFPersonaContacto = new javax.swing.JTextField();
        TFEmailsResultados = new javax.swing.JTextField();
        TFEmailsOtros = new javax.swing.JTextField();
        BAceptar = new javax.swing.JButton();
        BCancelar = new javax.swing.JButton();
        TFCondicionesFacturacion = new javax.swing.JTextField();

        setTitle("Registro de Cliente");
        setMinimumSize(getPreferredSize());
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                windowCloseEvent(evt);
            }
        });

        PRegistroCliente.setBorder(javax.swing.BorderFactory.createTitledBorder("Registro de Cliente"));

        jLabel1.setText("Nombre del Cliente:");

        jLabel2.setText("Identificación:");

        jLabel3.setText("Teléfonos:");

        jLabel4.setText("Teléfonos de Solicitud de Certificado de Retenciones:");

        jLabel5.setText("Fax:");

        jLabel6.setText("Dirección:");

        CBCorrespondencia.setSelected(true);
        CBCorrespondencia.setText("Correspondencia");

        CBDevolucionMuestras.setText("Devolución de Muestras");

        CBEnvioResultados.setText("Envío de Resultados");

        CBFacturacion.setText("Facturación");

        jLabel7.setText("Ciudad:");

        jLabel8.setText("Condiciones de Facturación:");

        jLabel9.setText("Persona Contacto:");

        jLabel10.setText("Emails autorizados para Envío de Resultados:");

        jLabel11.setText("Emails para Comunicación, Facturación Y/O Certificados de Retención:");

        BGIdentificacion.add(RBCC);
        RBCC.setSelected(true);
        RBCC.setText("CC");

        BGIdentificacion.add(RBNIT);
        RBNIT.setText("NIT");

        BGIdentificacion.add(RBOtro);
        RBOtro.setText("Otro");
        RBOtro.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                RBOtroItemStateChanged(evt);
            }
        });

        TFOtro.setEnabled(false);

        CBCondicionesFacturacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Al recibir la Muestra", "Fechas/Horarios de Radicación", "Lugar de Radicación", "Forma de Envío" }));
        CBCondicionesFacturacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBCondicionesFacturacionActionPerformed(evt);
            }
        });

        BAceptar.setText("Aceptar");
        BAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BAceptarActionPerformed(evt);
            }
        });

        BCancelar.setText("Cancelar");
        BCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCancelarActionPerformed(evt);
            }
        });

        TFCondicionesFacturacion.setEnabled(false);

        javax.swing.GroupLayout PRegistroClienteLayout = new javax.swing.GroupLayout(PRegistroCliente);
        PRegistroCliente.setLayout(PRegistroClienteLayout);
        PRegistroClienteLayout.setHorizontalGroup(
            PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PRegistroClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TFEmailsResultados))
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TFEmailsOtros))
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TFTelefonosRetenciones))
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TFPersonaContacto)
                            .addComponent(TFCiudad)
                            .addComponent(TFDireccion)
                            .addComponent(TFFax)
                            .addGroup(PRegistroClienteLayout.createSequentialGroup()
                                .addComponent(TFIdentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(RBCC)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(RBNIT)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(RBOtro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(TFOtro))
                            .addComponent(TFTelefonos)
                            .addGroup(PRegistroClienteLayout.createSequentialGroup()
                                .addComponent(CBCorrespondencia)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(CBDevolucionMuestras)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(CBEnvioResultados)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(CBFacturacion)
                                .addGap(0, 22, Short.MAX_VALUE))
                            .addComponent(TFNombreCliente)))
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addComponent(BAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(BCancelar)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(PRegistroClienteLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(CBCondicionesFacturacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(TFCondicionesFacturacion)))
                .addContainerGap())
        );
        PRegistroClienteLayout.setVerticalGroup(
            PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PRegistroClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(TFNombreCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(TFIdentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(RBCC)
                    .addComponent(RBNIT)
                    .addComponent(RBOtro)
                    .addComponent(TFOtro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(TFTelefonos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(TFTelefonosRetenciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(TFFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(TFDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CBCorrespondencia)
                    .addComponent(CBDevolucionMuestras)
                    .addComponent(CBEnvioResultados)
                    .addComponent(CBFacturacion))
                .addGap(4, 4, 4)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(TFCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(CBCondicionesFacturacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TFCondicionesFacturacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(TFPersonaContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(TFEmailsResultados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(TFEmailsOtros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(PRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BAceptar)
                    .addComponent(BCancelar))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PRegistroCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PRegistroCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BAceptarActionPerformed
        
        Cliente nuevoCliente = new Cliente();
        
        nuevoCliente.setNombre(TFNombreCliente.getText().trim());
        nuevoCliente.setAbreviatura(null);
        nuevoCliente.setIdentificacion(TFIdentificacion.getText().trim());
        nuevoCliente.setTelefonos(TFTelefonos.getText().trim());
        nuevoCliente.setCiudad(TFCiudad.getText().trim());
        nuevoCliente.setCondicionesFacturacion(CBCondicionesFacturacion.getSelectedItem().toString()
                + TFCondicionesFacturacion.getText().trim());
        nuevoCliente.setCorrespondencia(CBCorrespondencia.isSelected());
        nuevoCliente.setDevolucionMuestras(CBDevolucionMuestras.isSelected());
        nuevoCliente.setEnvioResultados(CBEnvioResultados.isSelected());
        nuevoCliente.setFacturacion(CBFacturacion.isSelected());
        
        if(RBCC.isSelected())
            nuevoCliente.setTipoIdentificacion("Cedula");
        else if(RBNIT.isSelected())
            nuevoCliente.setTipoIdentificacion("NIT");
        else if(RBOtro.isSelected())
            nuevoCliente.setTipoIdentificacion(TFOtro.getText().trim());
        
        nuevoCliente.setDireccion(TFDireccion.getText().trim());
        //Calendar fecha = Calendar.getInstance();
       // nuevoCliente.setFechaRegistro(fecha.getIdnstance().getTime());
        nuevoCliente.setEmailsComunicacion(TFEmailsResultados.getText().trim());
        //nuevoCliente.setFechaRegistro(fecha.getTime());
        java.util.Date fechaActual = new java.util.Date();
        java.sql.Date SQLFechaActual = new java.sql.Date(fechaActual.getTime()); 
//        java.sql.Time SQLHoraActual = new java.sql.Time(fechaActual.getTime());        
        nuevoCliente.setFechaRegistro(SQLFechaActual);
        try {
            boolean resultado = controlCliente.registrarCliente(nuevoCliente);
            if(resultado){
                JOptionPane.showMessageDialog(this, "Cliente Registrado Satisfactoriamente",
                        "Creación exitosa", javax.swing.JOptionPane.INFORMATION_MESSAGE);
                this.cerrar();
            }
            
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getClass() + ": " + ex.getMessage(), "Error",
                    javax.swing.JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_BAceptarActionPerformed

    private void BCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCancelarActionPerformed
        this.cerrar();
    }//GEN-LAST:event_BCancelarActionPerformed

    private void windowCloseEvent(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowCloseEvent
        this.cerrar();
    }//GEN-LAST:event_windowCloseEvent

    private void RBOtroItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RBOtroItemStateChanged
        if(RBOtro.isSelected()) TFOtro.setEnabled(true);
        else{
            TFOtro.setEnabled(false);
            TFOtro.setText(null);
        }
    }//GEN-LAST:event_RBOtroItemStateChanged

    private void CBCondicionesFacturacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBCondicionesFacturacionActionPerformed
        if(CBCondicionesFacturacion.getSelectedIndex() == 0){
            TFCondicionesFacturacion.setEnabled(false);
            TFCondicionesFacturacion.setText(null);
        }else{
            TFCondicionesFacturacion.setEnabled(true);
        }
    }//GEN-LAST:event_CBCondicionesFacturacionActionPerformed
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
                javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FRegistroClientes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new FRegistroClientes().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BAceptar;
    private javax.swing.JButton BCancelar;
    private javax.swing.ButtonGroup BGIdentificacion;
    private javax.swing.JComboBox CBCondicionesFacturacion;
    private javax.swing.JCheckBox CBCorrespondencia;
    private javax.swing.JCheckBox CBDevolucionMuestras;
    private javax.swing.JCheckBox CBEnvioResultados;
    private javax.swing.JCheckBox CBFacturacion;
    private javax.swing.JPanel PRegistroCliente;
    private javax.swing.JRadioButton RBCC;
    private javax.swing.JRadioButton RBNIT;
    private javax.swing.JRadioButton RBOtro;
    private javax.swing.JTextField TFCiudad;
    private javax.swing.JTextField TFCondicionesFacturacion;
    private javax.swing.JTextField TFDireccion;
    private javax.swing.JTextField TFEmailsOtros;
    private javax.swing.JTextField TFEmailsResultados;
    private javax.swing.JTextField TFFax;
    private javax.swing.JTextField TFIdentificacion;
    private javax.swing.JTextField TFNombreCliente;
    private javax.swing.JTextField TFOtro;
    private javax.swing.JTextField TFPersonaContacto;
    private javax.swing.JTextField TFTelefonos;
    private javax.swing.JTextField TFTelefonosRetenciones;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    // End of variables declaration//GEN-END:variables
    private ControlCliente controlCliente = new ControlCliente();
    private JFrame padre;
}
